"""
Test that a JoinTrack camera calibration file can be accurately applied.

"""
import pythonRegistration as pr
from numpy import array, ones
import itk
import ImageCompare

reload(pr)

reg=pr.registration()
reg.verbose = False

fixedFileName = 'C:/Lib/JointTrack/branches/bryan/Images/ushortim080-LAT.tif'
volFileName = 'C:/Lib/jointtrack/branches/TestData/vert1.vtk'
calFileName = 'C:/Lib/JointTrack/branches/bryan/Tests/good_cal.txt'
saveFileName = fixedFileName[:-4]+'_out.png'

reg.SetFixedImageFileName(fixedFileName)
reg.SetVolumeFileName(volFileName)

print "Original MovingImageCam Position: ", reg.movingImageCam.GetPosition()
reg.SetCalibration(calFileName)
print "Calibrated MovingImageCam Position: ", reg.movingImageCam.GetPosition()
print "Volume Position: ", reg.volume.GetPosition()
print reg.movingImageCam
print reg.volume
#Set the moving image to be black on white to match the fixed image
reg.SetBlackOnWhiteMovingImage()

reg.SetWindowNames()

reg.StartInteraction()

#return 0 if they match, 1 otherwise.
comp = 0

#Test for positive match
assert comp==0

if comp == 0:
    print "Test Success!"
else:
    print "Test Failure!"

